package com.kl.component.shiro.tag;

import com.jagregory.shiro.freemarker.PermissionTag;
import org.apache.commons.lang3.StringUtils;

/**
 * shiro 是否包含其中一个权限
 *
 * @author sunray_zjb
 * @date 2017/12/28
 *
 * #shiro扩展标签#
 *
 */
public class HasAnyPermissionTag extends PermissionTag {

    public HasAnyPermissionTag() {
    }

    protected boolean showTagBody(String p) {
        if(StringUtils.isEmpty(p)){
            return false;
        }
        String [] ps = p.split(",");
        boolean panss = false;
        for(String permission: ps){
            panss = this.isPermitted(permission);
            if(panss){
                break;
            }
        }
        return panss;
    }

}
